package com.ulook.lookplanet.widget;

import android.content.Context;
import android.graphics.Bitmap;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.qmuiteam.qmui.widget.QMUIRadiusImageView2;
import com.ulook.lookplanet.R;

/**
 * 描述：
 *
 * @author L1998
 * @data 2021/5/8
 */
public class MyMsgView extends LinearLayout {

    private Context context;
    private QMUIRadiusImageView2 mHead;
    private TextView mTime;
    private TextView mMsg;

    public MyMsgView(Context context) {
        super(context);
        ininMsg(context);
    }

    public MyMsgView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        ininMsg(context);
    }

    public MyMsgView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        ininMsg(context);
    }

    private void ininMsg(Context context){
        this.context = context;
        LayoutInflater.from(context).inflate(R.layout.widget_my_msg, this, true);
        mHead = findViewById(R.id.w_my_msg_head);
        mTime = findViewById(R.id.w_my_msg_time);
        mMsg = findViewById(R.id.w_my_msg_tx);
    }

    /**
     * 设置头像
     */
    public void setHead(Bitmap bitmap){
        if (bitmap != null){
            mHead.setImageBitmap(bitmap);
        }
    }

    /**
     * 设置时间
     */
    public void setTime(String time){
        mTime.setText(time);
    }

    /**
     * 设置消息
     */
    public void setMsg(String msg){
        mMsg.setText(msg);
    }
}
